package com.shilan.administrator.qintfm.volley;

import android.graphics.Bitmap;
import android.widget.ImageView;

import com.android.volley.AuthFailureError;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageRequest;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by dllo on 16/1/20.
 */
public  class GetBitmap {

   private static VolleySingleton  volleySingleton = VolleySingleton.getInstance();

    // 封装的圆形图片的请求
    public static void getBitmap(String url, final ImageView imageView) {
        ImageRequest request = new ImageRequest(url,
                new Response.Listener<Bitmap>() {
                    @Override
                    public void onResponse(Bitmap response) {

//                        imageView.setImageBitmap(ImageViewEffect.oldRemeber(response));
                        imageView.setImageBitmap(response);
                    }
                }, 700, 200, Bitmap.Config.ARGB_8888,
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {

                    }
                }) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                HashMap<String, String> map = new HashMap<>();
                map.put("Accept-Encoding", "");
                return map;
            }
        };
      volleySingleton.addRequest(request);
    };
}
